# -*- coding: utf-8 -*-
# @author: 龙非池
from __future__ import unicode_literals

from django.db import models


# API调用日志抽象类
class ELAPIlog(models.Model):
    time = models.DateTimeField('请求时间', null=True, auto_now=True, db_index=True)
    code = models.CharField("调用状态", null=True, max_length=10)
    request = models.TextField("请求内容", null=True)
    response = models.TextField("返回结果", null=True)

    class Meta:
        abstract = True


# 风报API调用日志
class ELFBlog(ELAPIlog):
    regno = models.CharField('工商注册号', null=True, blank=True, max_length=30, db_index=True)
    ftype = models.SmallIntegerField("接口类型", null=True, blank=True, default=0, db_index=True,
                                     choices=((1, "事件"), (2, "招投标"), (3, "土地"), (4, "著作权"), (5, "ICP"),))
    hits = models.IntegerField("命中个数", null=True, blank=True)

    class Meta:
        verbose_name = '风报api日志'
        verbose_name_plural = '风报api日志'
        db_table = 'api_fblog'


# 文木源API调用日志
class ELWmylog(ELAPIlog):
    choose = (
    (101, "招聘职位列表"), (102, "招聘公司信息"), (103, "薪资分布"), (104, "其他分布"), (2, "招投标"), (301, "ICP备案"), (302, "网站运营状况"),
    (4, "税务违法"), (5, "环保违法"), (6, "土地"), (7, "住房建设"), (8, "房产信息"), (901, "普通高校信息"), (902, "成人高校信息"), (10, "质检信息"),
    (11, "海关"),)
    company_name = models.CharField('企业名称', max_length=150, null=True, blank=True, db_index=True)
    ftype = models.SmallIntegerField("接口类型", null=True, blank=True, default=0, db_index=True, choices=choose)
    hits = models.IntegerField("命中个数", null=True, blank=True)

    class Meta:
        verbose_name = '文木源API日志'
        verbose_name_plural = '文木源API日志'
        db_table = 'api_wmylog'
